{extend name="template/base" /}
{block name="style"}
<!--select2样式 start -->
<link href="__LIB__/select2-4.0.3/dist/css/select2.min.css" rel="stylesheet" />
<style>
    .evaluate_top_info{
        background-color: #f5fafe;
        margin-left: 10px;
        margin-right: 10px;
    }
    .evaluate_text{
        text-align: left;
        margin-bottom: 5px;
        margin-left: 10px;
        margin-right: 10px;
        font-weight: normal;
        font-size: 16px;
    }
    .evaluate_info{
        text-align: left;
    }
    .evaluate_info p{
        font-weight: normal;
        font-size: 16px;
        min-width: 200px;
        max-width: 350px;
    }
    .evaluate_bottom_info{
        text-align: left
    }
    .evaluate_bottom_info p{
        font-weight: normal;
        font-size: 16px;
        margin-left: 10px;
        margin-right: 10px;
    }
    .img_nav{
        padding: 10px;
    }
    img{
        margin: 10px;
        width: 150px;
        /*height: auto;*/
        height: 100px;
    }
    .mr-b-10{
        margin-bottom: 10px;
    }
    .is_show{
        display: block;
    }
</style>
<!--select2样式 end -->
{/block}
{block name="content"}
<?php use think\Db;?>
{if $is_apply_good_reward == 1}
<div class="page-container">
    <form id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <table class="table table-border table-bordered table-hover table-bg mt-20" style="margin-bottom: 25px">
            <thead>
            <tr class="text-c">
                <th width="">派车单</th>
                <th width="">司机</th>
                <th width="">司机类型</th>
                <th width="">线路名称</th>
                <th width="">开户银行卡支行</th>
                <th width="">用户名</th>
                <th width="">银行卡号</th>
                <th width="">好评奖励</th>
                <th width="">申请时间</th>
                <th width="">累计好评奖励</th>
                <th width="">结算状态</th>
                <th width="">备注</th>
                <th width="70">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c">
                <td>{$data.dispatch_group_id}</td>
                <td>{$data.realname}</td>
                <td>{$data.driver_type}</td>
                <td>{$data.route_title}</td>
                <td>{$data.bank_name}</td>
                <td>{$data.user_name}</td>
                <td>{$data.card_num}</td>
                <td>
                    <span id="award_c{$data.id}">{$data.award}</span>
                    <input class="input-text" type="text" id="award{$data.id}" name="award" value="{$data.award?:'0'}" style="display: none">
                </td>
                <td>{:date('Y-m-d H:i:s',$data.apply_time)}</td>
                <td>{$data.accumulative_award?:'0'}</td>
                <td>
                    {php}
                        switch ($data['status']){
                            case '0':
                                echo '结算驳回';break;
                            case '1':
                                echo '结算成功';break;
                            case '2':
                                echo '申请中';break;
                        }
                    {/php}
                </td>
                <td>
                    <span id="remark_c{$data.id}">{$data.remark}</span>
                    <textarea class="textarea" id="remark{$data.id}" name="remark" style="display: none;">{$data.remark}</textarea>
                </td>
                <td class="f-14">
                    {if $data.status == 2}
                        <a title="修改信息" href="javascript:;" id="edit{$data.id}" onclick="edit(this,'{$data.id}')" class="label label-warning radius" >修改信息</a>
                        <a title="取消修改" href="javascript:;" id="canelEdit{$data.id}" onclick="canelEdit(this,'{$data.id}')" style="display: none" class="label label-warning radius" >取消修改</a>
                    {/if}
                    {if $data.status == 0}
                        <a title="再次申请" href="javascript:;" id="reapply{$data.id}" onclick="reapply(this,'{$data.id}')" class="label label-warning radius" >再次申请</a>
                        <a title="取消修改" href="javascript:;" id="canelReapply{$data.id}" onclick="canelReapply(this,'{$data.id}')" style="display: none" class="label label-warning radius" >取消申请</a>
                    {/if}
                </td>
            </tr>
            </tbody>
        </table>
        <div id="reapply_btn" class="row cl" style="text-align: center;display: none">
            <input type="hidden" name="is_apply_good_reward" value="1">
            <input type="hidden" name="group_id" value="{$data.dispatch_group_id}">
            <input type="hidden" name="status" value="{$data.status}">
            <div class="col-xs-8 col-sm-9 col-xs-offset-2 col-sm-offset-1">
                <button type="button" class="btn btn-primary radius" onclick="submitSriver()" >&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
            </div>
        </div>
        <div id="edit_btn" class="row cl" style="text-align: center;display: none">
            <div class="col-xs-8 col-sm-9 col-xs-offset-2 col-sm-offset-1">
                <button type="button" class="btn btn-primary radius" onclick="submitSriver()">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{else/}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="group_id" value="{$data.group_id ?? ''}">
        <input type="hidden" name="is_apply_good_reward" value="0">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">好评奖励：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="好评奖励金额" name="award" value="{$data.award ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">好评奖励备注：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <textarea  name="remark" class="textarea">{$data.remark ?? ''}</textarea>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <div id="content"></div>
                <input id="type" name="type" type="text" style="display: none" value="{$type}">
                <button type="button" class="btn btn-primary radius"onclick="submitSriver()">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/if}

{/block}
{block name="script"}

<!--时间插件-->
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/template/template.js"></script>
<!--select2 js 插件-->
<script type="text/javascript" src="__LIB__/select2-4.0.3/dist/js/select2.min.js"></script>
<script type="text/javascript" src="__LIB__/layer/2.4/layer.js"></script>
<script>
    // 显示编辑输入框
    function edit(obj, id) {

        var award_c = "#award_c" + id;
        $(award_c).css('display','none');
        var remark_c = "#remark_c" + id;
        $(remark_c).css('display','none');
        var award = "#award" + id;
        $(award).css('display','inline');
        var remark = "#remark" + id;
        $(remark).css('display','inline');
        var saveEdit = "#saveEdit" + id;
        $(saveEdit).css('display','inline');
        // 隐藏编辑按钮，显示提交和取消按钮
        var edit = "#canelEdit" + id;
        $(edit).css('display','inline');
        $("#edit_btn").css('display','inline');
        $(obj).css('display','none');

    }

    // 取消编辑
    function canelEdit(obj, id) {
        // 恢复原来的样子,隐藏输入框和显示数据
        var award_c = "#award_c" + id;
        $(award_c).css('display','inline');
        var remark_c = "#remark_c" + id;
        $(remark_c).css('display','inline');
        var award = "#award" + id;
        $(award).css('display','none');
        var remark = "#remark" + id;
        $(remark).css('display','none');
        var saveEdit = "#saveEdit" + id;
        $(saveEdit).css('display','none');
        // 显示编辑按钮，隐藏提交和取消按钮
        var edit = "#edit" + id;
        $(edit).css('display','inline');
        $("#edit_btn").css('display','none');
        $(obj).css('display','none');
    }

    function reapply(obj, id) {

        var award_c = "#award_c" + id;
        $(award_c).css('display','none');
        var remark_c = "#remark_c" + id;
        $(remark_c).css('display','none');
        var award = "#award" + id;
        $(award).css('display','inline');
        var remark = "#remark" + id;
        $(remark).css('display','inline');
        var saveEdit = "#saveEdit" + id;
        $(saveEdit).css('display','inline');
        // 隐藏编辑按钮，显示提交和取消按钮
        var edit = "#canelReapply" + id;
        $(edit).css('display','inline');
        $("#reapply_btn").css('display','inline');
        $(obj).css('display','none');

    }

    function canelReapply(obj, id) {
        // 恢复原来的样子,隐藏输入框和显示数据
        var award_c = "#award_c" + id;
        $(award_c).css('display','inline');
        var remark_c = "#remark_c" + id;
        $(remark_c).css('display','inline');
        var award = "#award" + id;
        $(award).css('display','none');
        var remark = "#remark" + id;
        $(remark).css('display','none');
        var saveEdit = "#saveEdit" + id;
        $(saveEdit).css('display','none');
        // 显示编辑按钮，隐藏提交和取消按钮
        var edit = "#reapply" + id;
        $(edit).css('display','inline');
        $("#reapply_btn").css('display','none');
        $(obj).css('display','none');
    }

    function saveEdit(id) {

    }
    function open_img(src) {
        window.open(src);
    }
    function submitSriver() {
        $.ajax({
            type: 'post',
            url: '/admin/dispatch_traveler_group/good_reward',
            data: $('#form').serializeArray(),
            success: function (data) {
                console.log('data', data);
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 1,
                        shift: -1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引\
                        parent.layer.close(index)
                    });
                } else {
                    layer.msg(data.msg, {
                        icon: 5,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    });
                }
            },
            error: function (data) {
                layer.msg(data.msg, {
                    icon: 5,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
                console.log('data', data);
            }
        });
        return false
    }
</script>
{/block}
